from django.db import models
from apps.users.models import User

class RestRecord(models.Model):
    STATUS_CHOICES = (
        ('completed', '已完成'),
        ('interrupted', '中断'),
    )
    
    CATEGORY_CHOICES = (
        ('eye', '眼部放松'),
        ('stretch', '伸展运动'),
        ('meditation', '冥想放松'),
        ('walk', '散步放松'),
        ('water', '喝水休息'),
        ('social', '社交休息'),
    )

    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='rest_records')
    start_time = models.DateTimeField(auto_now_add=True)
    duration = models.IntegerField(help_text='休息时长（秒）')
    category = models.CharField(max_length=20, choices=CATEGORY_CHOICES)
    flag = models.CharField(max_length=20, choices=STATUS_CHOICES)
    created_at = models.DateTimeField(auto_now_add=True)
    actual_duration = models.IntegerField(null=True, blank=True, help_text='实际休息时长（秒）')

    class Meta:
        db_table = 'rest_record'
        ordering = ['-created_at'] 